import React, { Component } from 'react'
import { Container, Content } from 'native-base'
import { View, TouchableOpacity, Text, DeviceEventEmitter } from 'react-native'
import DialogCom from '../dialog'
import TipsCom from '../dialog/tips'
import { getAwardOneApi } from './data'
import { connect } from 'react-redux' // 引入connect函数

class Tipscontainer extends Component {
	constructor(props) {
		super(props)
		this.state = {
			dialogForbidVisible: false,
			dialogForbidContent: '',
			dialogForbidTitle: '封号处罚'
		}
	}
	componentWillMount() {
		DeviceEventEmitter.addListener('forbid.user', () => {
			if (this.state.dialogForbidVisible) return
			this.setState({
				dialogForbidVisible: true,
				dialogForbidContent: 
					'很抱歉，经系统检测您的账号存在违规行为，现已封号处理，如有疑问请联系客服！微信客服: ' + this.props.serviceInfo.wechat
			})
		})
	}
	
	render() {
		return (
			<Container>
				<Content style={{ backgroundColor: '#f5f5f5' }}>
					{this.props.children}
					<DialogCom 
						titleStyle={
							{
								textStyle: {
									color: '#C30D23'
								}
							}
						}
						notOk={true}
						title={this.state.dialogForbidTitle}
						content={this.state.dialogForbidContent}
						visible={this.state.dialogForbidVisible} />
				</Content>
			</Container>
		)
	}
}

export default connect(
	state => ({
		userinfo: state.user.user || {},
		serviceInfo: state.login.serviceInfo
	})
)(Tipscontainer)
